﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using GestionEducativa.Models;

namespace GestionEducativa.DataLayer
{
    public class ConceptoDetalleRepository
    {
        Gestion_EducativaEntities ObjectContex = new Gestion_EducativaEntities();

      

        public void InsertarConceptoDetalle(ConceptoDetalle cd)
        {
            ObjectContex.AddToConceptoDetalle(cd);
            ObjectContex.SaveChanges();
        }

        public void ActualizarConceptoDetalle(ConceptoDetalle cdt)
        {

            ConceptoDetalle cd = ObjectContex.ConceptoDetalle.First(cdx => cdx.idconcepto == cdt.idconcepto);
  
            ObjectContex.SaveChanges();
        }

        public void BorrarConceptoDetalle(int idc)
        {
            ConceptoDetalle cd = ObjectContex.ConceptoDetalle.First(cdx => cdx.idconcepto == idc);
            ObjectContex.ConceptoDetalle.DeleteObject(cd);
            ObjectContex.SaveChanges();
        }

        public IEnumerable<ConceptoDetalle> TraerTodosConceptoDetalle()
        {
            IEnumerable<ConceptoDetalle> ListConceptoDetalleData = (from cdx in ObjectContex.ConceptoDetalle select cdx).AsEnumerable();
            return ListConceptoDetalleData;
        }

        public ConceptoDetalle TraerConceptoDetalle(int idc)
        {
            ConceptoDetalle ConceptoDetalleData = (from cdx in ObjectContex.ConceptoDetalle where cdx.idconcepto == idc select cdx).First();
            return ConceptoDetalleData;
        }
    }
}